﻿/////////////////////////////////////////////////////////////////
//File: CategoryDao.cs
//Description: 
//Copyright© 2011 Moliu
//History:
//  2011-3-26 18:11:20    CodeSmith5.0.1    Original Version
/////////////////////////////////////////////////////////////////

using MAF.CRUD;
using My.Blog.Domain.Entities;

namespace My.Blog.Database.Persistence
{
    public partial class CategoryDao : DatabaseCRUD<Article>
    {
        protected override string _MapAdd { get { return "Category.Add"; } }
        protected override string _MapUpdate { get { return "Category.Update"; } }
        protected override string _MapDelete { get { return "Category.Delete"; } }
        protected override string _MapSearch { get { return "Category.Search"; } }
        protected override string _MapCount { get { return "Category.Count"; } }

        private string _ReadAncestorsByConditionsSqlKey = "Categories.ReadAncestorsByConditions";
        private string _MoveToSqlKey = "Categories.MoveCategoryTo";

        // 构造函数
        public CategoryDao( string configFile,string tableName ) : base(configFile,tableName){}
 
        ///// <summary>
        ///// 列表
        ///// </summary>
        ///// <param name="info"></param>
        ///// <returns></returns>
        //public IList<CategoryInfo> ReadCategoriesByConditions(CategoryInfo info)
        //{
        //    Tree<CategoryInfo> tree = new Tree<CategoryInfo>();
        //    IList<CategoryInfo> list = map.QueryForList<CategoryInfo>(_ReadCategoriesByConditions, info);
        //    if (0 != info.BlogId && null != list && 0 < list.Count)
        //        return tree.OrderByTree(list, list[0].Id);
        //    else
        //        return tree.OrderByTree(list, info.Id);
        //}

        ///// <summary>
        ///// 祖先节点
        ///// </summary>
        ///// <param name="info"></param>
        ///// <returns></returns>
        //public IList<CategoryInfo> ReadAncestorsByConditions(CategoryInfo info)
        //{
        //    IList<CategoryInfo> list = map.QueryForList<CategoryInfo>(_ReadAncestorsByConditionsSqlKey, info);
        //    return list;
        //}


        ///// <summary>
        ///// 移动节点
        ///// </summary>
        ///// <param name="sourceId"></param>
        ///// <param name="targetId"></param>
        ///// <param name="width"></param>
        ///// <returns></returns>
        //public int MoveCategoryTo(int sourceId, int targetId, int width)
        //{
        //    CategoryInfo info = new CategoryInfo();
        //    info.Id = sourceId;
        //    info.ParentId = targetId;
        //    info.Width = width;
        //    return map.Update(_MoveToSqlKey, info);
        //}
     }
}
    